package com.turing.post.organization.util;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.turing.post.util.PCPSUtil;

/**
 * @author zxp
 * @Mar 12, 2013
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "IssueFeePolicy")
public class IssueFeePolicy implements Serializable {

	/**
	 * 策略ID
	 */
	private BigInteger feePolicyId;
	/**
	 * 名称
	 */
	private String feePolicyName;
	/**
	 * 发卡商No
	 */
	private String issueCompanyNo;
	/**
	 * 机构号
	 */
	private String saleBranchNo;

	/**
	 * 01-售卡
	 */
	public static final String IFPolicy_busiType_sale = "01";
	/**
	 * 02-充值
	 */
	public static final String IFPolicy_busiType_deposit = "02";
	/**
	 * 03-赎回
	 */
	public static final String IFPolicy_busiType_redemp = "03";
	/**
	 * 12-临时挂失
	 */
	public static final String IFPolicy_busiType_temporaryLoss = "12";
	/**
	 * 04-正式挂失
	 */
	public static final String IFPolicy_busiType_loss = "04";
	/**
	 * 17-卡解挂失
	 */
	public static final String IFPolicy_busiType_relieveLoss = "17";
	/**
	 * 05-挂失换卡
	 */
	public static final String IFPolicy_busiType_changeLossCard = "05";
	/**
	 * 06-换发新卡
	 */
	public static final String IFPolicy_busiType_changeNewCard = "06";
	/**
	 * 07-卡延期
	 */
	public static final String IFPolicy_busiType_CardExpired = "07";
	/**
	 * 11-卡改密
	 */
	public static final String IFPolicy_busiType_modifyPasswd = "11";
	/**
	 * 08-重置密码
	 */
	public static final String IFPolicy_busiType_resetPasswd = "08";
	/**
	 * 09-变更卡种类
	 */
	public static final String IFPolicy_busiType_changeClassic = "09";
	/**
	 * 10-登记实名信息
	 */
	public static final String IFPolicy_busiType_realName = "10";
	/**
	 * 13-卡冻结
	 */
	public static final String IFPolicy_busiType_freeze = "13";
	/**
	 * 14-解卡冻结
	 */
	public static final String IFPolicy_busiType_freezeSolution = "14";
	/**
	 * 15-卡锁定
	 */
	public static final String IFPolicy_busiType_lock = "15";
	/**
	 * 16-解卡锁定
	 */
	public static final String IFPolicy_busiType_lockFree = "16";
	/**
	 * 18-解除卡密码锁定
	 */
	public static final String IFPolicy_busiType_pwdUnLock = "18";
	/**
	 * 30-补磁
	 */
	public static final String IFPolicy_busiType_magnetic = "30";
	/**
	 * 60-账户管理费
	 */
	public static final String IFPolicy_busiType_managementFee = "60";
	/**
	 * 61-过期管理费
	 */
	public static final String IFPolicy_busiType_expiredManagementFee = "61";
	/**
	 * 业务种类
	 */
	private String businessType;
	/**
	 * 卡面Id
	 */
	private BigInteger cardFaceId;
	/**
	 * 卡种类ID
	 */
	private BigInteger cardClassicId;
	/**
	 * 目标卡种类
	 */
	private BigInteger toCardClassicId;
	/**
	 * 起始卡序号
	 */
	private String startCardSeqNo;
	/**
	 * 终止卡序号
	 */
	private String endCardSeqNo;
	/**
	 * 起始时间
	 */
	private Date startDate;
	/**
	 * 终止时间
	 */
	private Date endDate;
	/**
	 * 起始发生额
	 */
	private BigInteger startAmount;
	/**
	 * 终止发生额
	 */
	private BigInteger endAmount;
	/**
	 * 0 – 固定金额
	 */
	public static final String IFPolicy_FeeType_Fix = "0";
	/**
	 * 1 – 按发生额比率收取
	 */
	public static final String IFPolicy_FeeType_Ratio = "1";
	/**
	 * 消费折扣
	 */
	private String feeType;
	/**
	 * 0 – 现金
	 */
	public static final String IFPolicy_amountType_Cash = "0";
	/**
	 * 1 - 卡内扣
	 */
	public static final String IFPolicy_amountType_Card = "1";
	/**
	 * 2 –现金或卡内扣
	 */
	public static final String IFPolicy_amountType_CashOrCard = "2";
	/**
	 * 收费模式
	 */
	private String amountType;

	/**
	 * 收费周期
	 */
	private Integer feeCycle;
	/**
	 * 收费比率
	 */
	private Integer fixRatio;
	/**
	 * 固定金额
	 */
	private Integer fixFee;

	/**
	 * 0 无效
	 */
	public static final String IFPolicy_status_Invalid = "0";
	/**
	 * 1 无效待审核
	 */
	public static final String IFPolicy_status_InvalidWait = "1";
	/**
	 * 2 生效
	 */
	public static final String IFPolicy_status_Effective = "2";
	/**
	 * 3 生效待审
	 */
	public static final String IFPolicy_status_EffectiveWait = "3";
	
	/**
	 * 5 待审核
	 */
	public static final String IFPolicy_Wait_Auth = "5";

	/**
	 * 状态
	 */
	private String status;
	/**
	 * 创建人
	 */
	private BigInteger createOperId;
	/**
	 * 创建时间
	 */
	private Date createTime;
	/**
	 * 审批人
	 */
	private BigInteger authOperId;
	/**
	 * 审批时间
	 */
	private Date authTime;
	/**
	 * 备注
	 */
	private String remark;

	/**
	 * 计算出来的手续费
	 */
	private BigInteger fee;

	public IssueFeePolicy() {

	}

	@Id
	@Column(name = "feePolicyId")
	public BigInteger getFeePolicyId() {
		return feePolicyId;
	}

	public void setFeePolicyId(BigInteger feePolicyId) {
		this.feePolicyId = feePolicyId;
	}

	@Column(name = "feePolicyName")
	public String getFeePolicyName() {
		return feePolicyName;
	}

	public void setFeePolicyName(String feePolicyName) {
		this.feePolicyName = feePolicyName;
	}

	@Column(name = "issueCompanyNo")
	public String getIssueCompanyNo() {
		return issueCompanyNo;
	}

	public void setIssueCompanyNo(String issueCompanyNo) {
		this.issueCompanyNo = issueCompanyNo;
	}

	@Column(name = "saleBranchNo")
	public String getSaleBranchNo() {
		return saleBranchNo;
	}

	public void setSaleBranchNo(String saleBranchNo) {
		this.saleBranchNo = saleBranchNo;
	}

	@Column(name = "businessType")
	public String getBusinessType() {
		return businessType;
	}

	public void setBusinessType(String businessType) {
		this.businessType = businessType;
	}

	@Column(name = "cardFaceId")
	public BigInteger getCardFaceId() {
		return cardFaceId;
	}

	public void setCardFaceId(BigInteger cardFaceId) {
		this.cardFaceId = cardFaceId;
	}

	@Column(name = "cardClassicId")
	public BigInteger getCardClassicId() {
		return cardClassicId;
	}

	public void setCardClassicId(BigInteger cardClassicId) {
		this.cardClassicId = cardClassicId;
	}

	@Column(name = "toCardClassicId")
	public BigInteger getToCardClassicId() {
		return toCardClassicId;
	}

	public void setToCardClassicId(BigInteger toCardClassicId) {
		this.toCardClassicId = toCardClassicId;
	}

	@Column(name = "startCardSeqNo")
	public String getStartCardSeqNo() {
		return startCardSeqNo;
	}

	public void setStartCardSeqNo(String startCardSeqNo) {
		this.startCardSeqNo = startCardSeqNo;
	}

	@Column(name = "endCardSeqNo")
	public String getEndCardSeqNo() {
		return endCardSeqNo;
	}

	public void setEndCardSeqNo(String endCardSeqNo) {
		this.endCardSeqNo = endCardSeqNo;
	}

	@Column(name = "startDate")
	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	@Column(name = "endDate")
	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	@Column(name = "startAmount")
	public BigInteger getStartAmount() {
		return startAmount;
	}

	public void setStartAmount(BigInteger startAmount) {
		this.startAmount = startAmount;
	}

	@Column(name = "endAmount")
	public BigInteger getEndAmount() {
		return endAmount;
	}

	public void setEndAmount(BigInteger endAmount) {
		this.endAmount = endAmount;
	}

	@Column(name = "feeType")
	public String getFeeType() {
		return feeType;
	}

	public void setFeeType(String feeType) {
		this.feeType = feeType;
	}

	@Column(name = "amountType")
	public String getAmountType() {
		return amountType;
	}

	public void setAmountType(String amountType) {
		this.amountType = amountType;
	}

	@Column(name = "feeCycle")
	public Integer getFeeCycle() {
		return feeCycle;
	}

	public void setFeeCycle(Integer feeCycle) {
		this.feeCycle = feeCycle;
	}

	@Column(name = "fixRatio")
	public Integer getFixRatio() {
		return fixRatio;
	}

	public void setFixRatio(Integer fixRatio) {
		this.fixRatio = fixRatio;
	}

	@Column(name = "fixFee")
	public Integer getFixFee() {
		return fixFee;
	}

	public void setFixFee(Integer fixFee) {
		this.fixFee = fixFee;
	}

	@Column(name = "status")
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name = "createOperId")
	public BigInteger getCreateOperId() {
		return createOperId;
	}

	public void setCreateOperId(BigInteger createOperId) {
		this.createOperId = createOperId;
	}

	@Column(name = "createTime")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "authOperId")
	public BigInteger getAuthOperId() {
		return authOperId;
	}

	public void setAuthOperId(BigInteger authOperId) {
		this.authOperId = authOperId;
	}

	@Column(name = "authTime")
	public Date getAuthTime() {
		return authTime;
	}

	public void setAuthTime(Date authTime) {
		this.authTime = authTime;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
	 * yxb add
	 * 
	 * @return
	 */
	@Transient
	public BigInteger getFee() {
		return fee;
	}

	public void setFee(BigInteger fee) {
		this.fee = fee;
	}

	/**
	 * 判断指定业务类型是否与余额有关
	 * 
	 * @param bstype
	 * @return 0 - 与发生额相关 1 - 与余额相关 -1 - 非法的业务类型
	 */
	public static int isBalance(String bstype) {
		// 与发生额相关
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_sale))
			return 0;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_deposit))
			return 0;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_redemp))
			return 0;

		// 与余额相关
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_magnetic))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_pwdUnLock))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_freeze))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_freezeSolution))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_lock))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_lockFree))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_relieveLoss))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_temporaryLoss))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_loss))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_modifyPasswd))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_changeLossCard))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_changeNewCard))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_CardExpired))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_resetPasswd))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_changeClassic))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_realName))
			return 1;
		if (PCPSUtil.compareObject(bstype, IFPolicy_busiType_managementFee))
			return 1;
		if (PCPSUtil.compareObject(bstype,
				IFPolicy_busiType_expiredManagementFee))
			return 1;

		// 业务类型非法
		return (-1);
	}
}
